<!--
 * @Description: 本地时间
 * @Author: lwx
 * @Date: 2022-06-20 09:52:04
 * @LastEditors: lwx
 * @LastEditTime: 2023-04-12 09:47:39
-->
<template>
  <div class="localTime">{{nowTime}}</div>
</template>

<script>
import {localTime} from '@/api/dashboard.js'
export default { 
  data() {
    return {
      timer: null,
      nowTime:''
    };
  },
  mounted() {
    this.getLocalTime()
  },
  methods: {
   getLocalTime(){
     this.timer = setInterval(async ()=>{
       const {data}= await localTime()
       this.nowTime=data
     },1000)
    }
  },
  beforeDestroy() {
    if (this.timer) {
      clearInterval(this.timer);
    }
  },
};
</script>
<style lang='scss' scoped>
.localTime {
  position: absolute;
  right: 0.8rem;
  top: 0.8rem;
  font-size: .33rem;
  color: #17caf0;
  text-shadow: 0 0 0.0938rem #17caf0;
}
</style>